//添加某个样式

function addClass(curEle,newClass){
    var ary = newClass.split(/ +/g);
    
    for(var i = 0; i < ary.length; i++ ){
        if(!hasClass(curEle,ary[i])){
            curEle.className += (" " + ary[i]);
        }
    }
    console.log(curEle.className);
}

//  <div class="box position clear border">

//判断curEle元素节点的样式类名中是否有classname这个样式

function hasClass(curEle,classname){
    var reg = new RegExp("( +|^)" + classname + "( +|$)");
    
    return reg.test(curEle.className);


}

//去除某个样式

function removeClass(curEle,classname){
    var ary = classname.split(/ +/g);
    console.log(ary);
    for(var i = 0; i < ary.length; i++ ){
        if(hasClass(curEle,ary[i])){
            var reg = new RegExp("( +|^)" + ary[i] + "( +|$)");
            
            curEle.className = curEle.className.replace(reg," ");
        }
    }
}







